//
//  NewAddressSpecialView.m
//  FD
//
//  Created by xiaofang wang on 2018/10/29.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//2019-1-7 废弃



#import "NewAddressSpecialView.h"
@interface NewAddressSpecialView()
/**左边的 小区/写字楼/学校*/
@property (nonatomic, strong) UIButton *leftBtn;

@end

@implementation NewAddressSpecialView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
        
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setupView {
    CGFloat sh = self.bounds.size.height;
    CGFloat sw = self.bounds.size.width;
    CGFloat h = 20;
    CGFloat y = (sh - h)*0.5;

    self.leftBtn.frame = CGRectMake(15, y, 180, h);
    [self addSubview:self.leftBtn];
    
    [self.leftBtn leftTextRightImageWithMargin:2]; //调整文字图片位置
    
    CGFloat w2 = sw - self.leftBtn.rb_right - 10 - 10;
    self.rightBtn.frame = CGRectMake(self.leftBtn.rb_right + 10,y, w2, h);
    [self addSubview:self.rightBtn];
}

//getter
- (UIButton *)leftBtn {
    if (!_leftBtn) {
        _leftBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_leftBtn setImage:[UIImage imageNamed:@"address"] forState:(UIControlStateNormal)];
        //国际化
        NSString *xqxuxzlStr = NSLocalizedString(XiaoQuSchoolEtc, @"小区/写字楼/学校等");
        [_leftBtn setTitle:xqxuxzlStr forState:(UIControlStateNormal)];
        [_leftBtn setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    }
    return _leftBtn;
}
- (UIButton *)rightBtn {
    if (!_rightBtn) {
        _rightBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_rightBtn setTitleColor:[UIColor lightGrayColor] forState:(UIControlStateNormal)];
        //国际化
        NSString *xzscdzStr = NSLocalizedString(ChooseAddress, @"请选择送餐地址 >");
        [_rightBtn setTitle:xzscdzStr forState:(UIControlStateNormal)];
        [_rightBtn addTarget:self action:@selector(clickSelectedAddress:) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _rightBtn;
}

- (void)clickSelectedAddress:(UIButton *)btn {
    FDLog(@"选择地址");
    
    if (self.clickAddressBlock) {
        self.clickAddressBlock(btn);
    }
}


@end
